package router

import (
	// "beesoft.ink/application/text/app/api/auth"
	// "beesoft.ink/application/text/app/api/base"
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"github.com/spf13/viper"
)

func Init(c *echo.Echo) {
	router := c.Group("/api")

	Base(router)
	AuthBefore(router)
	Common(router)
	// test
	Translation(router)

	r := router.Group("")
	r.Use(middleware.JWTWithConfig(middleware.JWTConfig{
		SigningKey: []byte(viper.GetString("server.key")),
		ContextKey: "token",
		// Claims:     &jwt.MapClaims{},
	}))

	AuthAfter(r)
	// Category(r)
	// Vehicle(r)

}

func AuthBefore(router *echo.Group) {
	// r := router.Group("/auth")
	//
	// r.POST("/send-verification-code", auth.Auth.SendVerificationCode) // 发送验证码
	// r.POST("/login", auth.Auth.Login)                                 // 登录
}
func Common(router *echo.Group) {
	// r := router.Group("/base")

	// r.GET("/categories", base.Garage.Categories) // 分类
	// r.GET("/garages", base.Garage.Garages)       // 仓库
}

func Base(router *echo.Group) {
	r := router.Group("/vehicles")

	r.GET("/metrics", echo.WrapHandler(promhttp.Handler()))
}

// test

func Translation(router *echo.Group) {
	// r := router.Group("/translation")
	//
	// r.GET("/ifly", test.Translation.Ifly)
	// r.GET("/iflyv1", test.Translation.IflyV1)
	// r.GET("/iflyn", test.Translation.IflyN)
	// r.GET("/tencent", test.Translation.Tencent)
}

func AuthAfter(router *echo.Group) {
	// r := router.Group("/auth")
	//
	// r.POST("/logout", auth.Auth.Logout)
	// r.GET("/profile", auth.Auth.Profile)
	// r.POST("/setting", auth.Auth.Setting)
}

// func Category(router *echo.Group) {
// 	r := router.Group("/categories")
//
// 	r.GET("", base.Category.List)
// 	r.GET("/:id", base.Category.Show)
// 	r.POST("", base.Category.Store)
// 	r.PUT("/:id", base.Category.Update)
// 	r.DELETE("/:id", base.Category.Destroy)
// }

// func Vehicle(router *echo.Group) {
// 	r := router.Group("/vehicles")
//
// 	r.GET("", garage.Vehicle.List)
// 	r.GET("/:id", garage.Vehicle.Show)
// 	r.POST("", garage.Vehicle.Store)
// 	r.PUT("/:id", garage.Vehicle.Update)
// 	r.DELETE("/:id", garage.Vehicle.Destroy)
// }
